import axios from 'axios'
// 创建axios实例
let service = axios.create({
    // baseURL: 'http://127.0.0.1:8888/subject/',
    // baseURL: 'http://miraclepeak.xyz:8086/',
    baseURL: 'http://miraclepeak.xyz:8888/subject/',
    // baseURL: 'http://47.52.72.145:8888/subject/',
    timeout: 4000,
})


/**
 * 请求拦截
 */
service.interceptors.request.use(config => {
    // config.headers['token'] = Vue.cookie.get('token') // 请求头带上token
    if (localStorage.JWT_TOKEN) {  // 判断是否存在token，如果存在的话，则每个http header都加上token
        config.headers.Authorization = `${localStorage.JWT_TOKEN}`;
        // config.headers.Authorization = `token ${localStorage.JWT_TOKEN}`;
    }
    return config
}, error => {
    console.log("reject--->", error)
    return Promise.reject(error)
})

export default  service
